#include <func.h>

int shendu(char*path,int depth)
{
    DIR *dir;
    dir=opendir(path);
    ERROR_CHECK(dir,NULL,"opendir");
    char buf[1024];
    struct dirent *p;
    while((p=readdir(dir))){
        if(!strcmp(".",p->d_name)||!strcmp("..",p->d_name)){}
        else {
            printf("%*s%s\n",depth,"",p->d_name);
            if(p->d_type==4){
                memset(buf,0,sizeof(buf));
                sprintf(buf,"%s%s%s",path,"/",p->d_name);
                shendu(buf,depth+4);
            }
        }
    }
}


int main(int argc,char*argv[])
{
    ARGS_CHECK(argc,2);
    shendu(argv[1],0);
    return 0;
}

